package base_grammar

import "fmt"

/* 常量 */

func Constant() {

	// 常量
	const PI float32 = 3.14
	const PI2 = 3.1415

	fmt.Printf("PI: %v\n", PI)

	const (
		a = 100
		b = 200
	)

	fmt.Printf("a: %v\n", a)
	fmt.Printf("b: %v\n", b)

	const e, c, d = 1, "b", false
	fmt.Printf("e: %v\n", e)
	fmt.Printf("c: %v\n", c)
	fmt.Printf("d: %v\n", d)

	// iota  从0开始  遇到constant +1
	const (
		a1 = iota // 0
		a2 = iota // 1
		a3 = iota //2
	)

	fmt.Printf("a1: %v\n", a1)
	fmt.Printf("a2: %v\n", a2)
	fmt.Printf("a3: %v\n", a3)

	const (
		b1 = iota // 0
		_         // 跳过1
		b3 = iota //2
	)

	fmt.Printf("b1: %v\n", b1)
	fmt.Printf("b3: %v\n", b3)

	const (
		c1 = iota // 0
		c2 = 100  // 跳过1
		c3 = iota //2
	)

	fmt.Printf("c1: %v\n", c1)
	fmt.Printf("c2: %v\n", c2)
	fmt.Printf("c3: %v\n", c3)

}
